home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VBMS.ZIP / BASIC.DOC next >
Text File  |  1992-10-16  |  11KB  |  233 lines

  1. VBMS: VERTICAL BAR MENU SCHEMATA;
  2. BASIC UNIT; V 1.oo (c) 1993
  3. by Ali KOCATURK
  4.  
  5. ==============================================================================
  6. The following files should be included in this package;
  7. BASIC.TPU           Basic Unit
  8. BASIC.DOC           Unit Documentation
  9. ==============================================================================
  10.  
  11. BASIC.TPU  contains a library of string functions/procedures as
  12. well as some screen design tools.  The objective is to approach
  13. to the well_known 'basic'  programing techniques.The following
  14. functions/procedures are defined in Unit.
  15. ==============================================================================
  16.  
  17. FUNCTION len(xstr: string): integer;
  18. FUNCTION midstr(xstr: string; first, number: integer): string;
  19. FUNCTION leftstr(xstr: string; number: integer): string;
  20. FUNCTION rightstr(xstr: string; number: integer): string;
  21. FUNCTION instr(xstr, ystr: string): integer;
  22. FUNCTION charpos(tstr: char; xstr: string): byte;
  23. FUNCTION ucasestr(xstr: string): string;
  24. FUNCTION lowercase(tstr: char): char;
  25. FUNCTION lcasestr(xstr: string): string;
  26. FUNCTION ltrimstr(xstr: string): string;
  27. FUNCTION rtrimstr(xstr: string): string;
  28. FUNCTION lrtrimstr(xstr: string): string;
  29. FUNCTION getstr; string;
  30. FUNCTION formatstr(xstr: string; lgth: byte): string;
  31. FUNCTION centerstr(xstr: string; width: byte): string;
  32. FUNCTION spacestr(x: integer): string;
  33. FUNCTION blankstr(x: integer): string;
  34. FUNCTION designstr(var space: integer; var design: char): string;
  35. FUNCTION yesno: char;
  36. PROCEDURE swap(xstr, ystr: string);
  37. PROCEDURE set_color(x, y: integer);
  38. PROCEDURE save_screen;
  39. PROCEDURE restore_screen;
  40. PROCEDURE setcursor(top, bottom: integer);
  41. PROCEDURE move_cursor;
  42. PROCEDURE box(wd_colm, wd_row, wd+lgth, wd_hgth: integer;
  43.               shadow, line: boolean);
  44. PROCEDURE border(wd_colm, wd_row, wd_lgth, wd_hgth: integer;
  45.                shadow: boolean);
  46. PROCEDURE draw(wd_colm, wd_row, n, m: integer; design: char);
  47. PROCEDURE screensetup;
  48. PROCEDURE clearkey;
  49. PROCEDURE beeper(freq, time: integer);
  50. PROCEDURE keycode(var code: byte; var status: boolean);
  51. ==============================================================================
  52.  
  53. FUNCTION len(xstr: string): integer;
  54. Returns the number of characters with leading and trailing spaces from
  55. the string.  If max_lgth:= len, then the string is called constant string.
  56. If len= zero then the string has no characters, therefore, null. A string
  57. has one character, it can be called character_string.  A character is simply
  58. one character of string; but it differs from a character_string. The one has
  59. a char type, the other string type. Subsequently, a string is an ordered po
  60. sitions of the number of characters with zero, one or more than one characters
  61. within a length.  The length in general is called space.  Operates similarly
  62. to the kength function.
  63.  
  64. Example:    xstr:= ' Vertical Menu.Schemata ';
  65.             writeln(length(xstr));
  66.                will display:  22;
  67.             writeln(len(xstr));
  68.                will display:  24;
  69. ------------------------------------------------------------------------------
  70. FUNCTION midstr(xstr: string; first, number: integer): string;
  71. Every character has a position in a given string. The ordered positions
  72. of the characters between two character positions is called substring of
  73. the string.
  74. Returns a string containing 'number' characters starting at first.
  75. Operates similarly to the copy function.
  76. Example:    writeln(copy(xstr, 1, 3));
  77.                will display: Ve;
  78.             writeln(midstr(xstr, 1, 3));
  79.                will display: Ve;
  80. ------------------------------------------------------------------------------
  81. FUNCTION leftstr(xstr: string; number: integer): string;
  82. Returns a string containing 'number' characters starting from
  83. 'number'--left. Operates similarly to the copy function.
  84. Example:    writeln(copy(xstr, 1, 1));
  85.                will display:  V;
  86.             writeln(leftstr(xstr, 1));
  87.                will display:  V;
  88. ------------------------------------------------------------------------------
  89. FUNCTION rightstr(xstr: string; number: integer): string;
  90. Returns a string containing 'number' characters starting from
  91. 'number'--right.  Operates similarly to the copy function, but
  92. string length is not required.
  93. Example:    writeln(copy(xstr, 21, 2));
  94.                will display:  at;
  95.             writeln(rightstr(xstr, 2));
  96.                will display:  a;
  97. ------------------------------------------------------------------------------
  98. FUNCTION instr(xstr, ystr: string): integer;
  99. Operates similarly to the pos function.
  100. ystr:='.';
  101. Example:    writeln(pos(xstr, ystr));
  102.                will display:    0;
  103.             writeln(instr(xstr, ystr));
  104.                will display:    0;
  105. ------------------------------------------------------------------------------
  106. FUNCTION charpos(tstr: char; xstr: string): byte;
  107. Returns a counted position of the character from a given  string.
  108. tstr:= 'M';
  109. Example:    writeln(charpos(tstr, xstr));
  110.                will display:     11;
  111. ------------------------------------------------------------------------------
  112. FUNCTION ucasestr(xstr: string): string;
  113. Returns a string in upper case with leading and trailing spaces.
  114. Example:    writeln('xstr');
  115.                will display: VERTICAL MENU.SCHEMATA;
  116. ------------------------------------------------------------------------------
  117. FUNCTION lowercase(tstr: char): char;
  118. Returns character in lowercase; opposite of the upcase function.
  119. Example:    writeln(upcase('a'));
  120.                will display:  A;
  121.             writeln(lowercase('A'));
  122.                will display:  a;
  123. ------------------------------------------------------------------------------
  124. FUNCTION lcasestr(xstr: string): string;
  125. Returns a string in lower case with leading and trailing spaces.
  126. Example:    writeln(lcasestr(xstr));
  127.                will display: Vertical Menu.Schemata;
  128. ------------------------------------------------------------------------------
  129. FUNCTION ltrimstr(xstr: string): string;
  130. Removes leading spaces from a string.
  131. Example:    writeln(ltrimstr(xstr));
  132.                will display: Vertical Menu.Schemata;
  133. ------------------------------------------------------------------------------
  134. FUNCTION rtrimstr(xstr: string): string;
  135. Removes trailing spaces from a string.
  136. Example:     writeln(rtrimstr(xstr));
  137.                 will display: Vertical Menu.Schemata;
  138. ------------------------------------------------------------------------------
  139. FUNCTION rltrimstr(xstr: string): string;
  140. Removes both leading and trailing spaces from a string.
  141. Example:    writeln(lrtrimstr(xstr));
  142.                 will display: Vertical Menu.Schemata;
  143. ------------------------------------------------------------------------------
  144. FUNCTION getstr: string;
  145. Reads a string that has a saved value; operates similarly to the readln func-
  146. tion.
  147. -------------------------------------------------------------------------------
  148. FUNCTION formatstr(xstr: string; lgth: byte): string;
  149. Formats a string for a given spaces.
  150. Example:     write(xstr: 10);
  151.              write(formatstr(xstr, 32));
  152.              will display: string at the same occupation.
  153. ------------------------------------------------------------------------------
  154. FUNCTION centerstr(xstr: string; width: byte): string;
  155. Returns a string centered on a specified space with len.
  156. Example:    write(centerstr(xstr, 32));
  157.                will display: at starting space_four.
  158. -------------------------------------------------------------------------------
  159. FUNCTION spacestr(x: integer): string;
  160. Returns a string of 'x' spaces
  161. Example:     set_color(0,0);
  162.              write(spacestr(5));
  163.                 will display: five_space colored bar.
  164. ------------------------------------------------------------------------------
  165. FUNCTION blankstr(x: integer): string;
  166. Operates similarly to spacestr; but it has length one_space more.
  167. Writes #255 for a specified space.
  168. Example:     gotoxy(8,18);
  169.              write(blankstr(27));
  170.                 will display: starting from cursor position
  171.                                erases twentyseven_spaces.
  172. ------------------------------------------------------------------------------
  173. FUNCTION designstr(var space: integer; var design: char):string;
  174. Draws high_ascii characters for a specified space.
  175. space:=12;
  176. design:=#178;
  177. Example:     writeln(designstr(space, design));
  178.                 will display:  #178 at twelve_spaces length.
  179. ------------------------------------------------------------------------------
  180. FUNCTION yesno: char;
  181. Asks input from the user.
  182. ------------------------------------------------------------------------------
  183. PROCEDURE swap(xstr, ystr: string);
  184. Swaps xstr by ystr.
  185. ystr:= 'VBMS'
  186. Example:     swap(xstr, ystr);
  187.              write(xstr);
  188.                 will display:  VBMS;
  189.              write(ystr);
  190.                 will display: Vertical Menu.Schemata
  191. ------------------------------------------------------------------------------
  192. PROCEDURE set_color(x, y: integer);
  193. Sets the specified colors for back and fore.
  194. Example:     set_color(1,1);
  195. ------------------------------------------------------------------------------
  196. PROCEDURE save_screen;
  197. PROCEDURE restore_screen;
  198. Saves and restores  the screen contents. With window call, if
  199. two windows have the same coordinates, the second window erases
  200. the first one, if not, the second is restored along with the
  201. first one.
  202. ------------------------------------------------------------------------------
  203. PROCEDURE set_cursor(top, bottom: integer);
  204. PROCEDURE movecursor;
  205. Sets and moves cursor for a specific location.
  206. ------------------------------------------------------------------------------
  207. PROCEDURE  box(wd_colm, wd_row, wd_lgth, wd_hgth: integer;
  208.                shadow, line: boolean);
  209. Draws a box at specified coordinates; fills with #177 or
  210. draws lines under the top and above bottom line.
  211. ------------------------------------------------------------------------------
  212. PROCEDURE border(wd_colm, wd_row, wd_lgth, wd_hgth: integer;
  213.                  shadow: boolean);
  214. Draws a box at specified coordinates and puts shadow for right
  215. and bottom sides.
  216. ------------------------------------------------------------------------------
  217. PROCEDURE draw(wd_colm, wd_row, n, m:integer; design: char);
  218. PROCEDURE screensetup;
  219. Designs screen with high_ascii characters for specified locátions.
  220. Screensetup is used as a shortcut routine.
  221. ------------------------------------------------------------------------------
  222. PROCEDURE clearkey;
  223. Clears the key buffer.
  224. ------------------------------------------------------------------------------
  225. PROCEDURE beeper(freq, time: integer);
  226. Writes #7 with some delay.
  227. ------------------------------------------------------------------------------
  228. PROCEDURE keycode(var code: byte; var status: boolean);
  229. Establishes ord value of any key with true or false setup.
  230. ==============================================================================
  231. ==============================================================================
  232.  
  233.